<?php

function dbconnect() 
	{ 
		require('../config.php'); 
		static $connect = null; 
		if ($connect === null) 
			{
				 $connect =  mysql_connect($host, $user, $passwd) or die(mysql_error());
				 mysql_query("SET character_set_results=utf8", $connect);
				 mysql_select_db($database); 
			} 
		return $connect; 
	} 
	
	function getid_auto_increment()
			{
		
		$r= mysql_query("SHOW TABLE STATUS LIKE 'Nha_cung_cap'",dbconnect());
		$row = mysql_fetch_array($r); 
        $n = $row['Auto_increment']; 
        return $n;
		
		} 
	function insert_ncc($post) 
	{ 
	 
		$query= mysql_query("INSERT INTO nha_cung_cap SET Ten_nha_cung_cap=N'".$post['Ten_nha_cung_cap']."', Dia_chi=N'".$post['Dia_chi']."', Dien_thoai=N'".$post['Dien_thoai']."', Email=N'".$post['Email']."', Ma_so_thue=N'".$post['Ma_so_thue']."', Thong_tin_them=N'".$post['Thong_tin_them']."' ", dbconnect());  
		
	}
	
	function getbyid_ncc($id)
	{
		$result= mysql_query("SELECT * FROM Nha_cung_cap WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}
	function update_ncc($post)
	{
	$query= mysql_query("UPDATE Nha_cung_cap SET Ten_nha_cung_cap=N'".$post['Ten_nha_cung_cap']."', Dia_chi=N'".$post['Dia_chi']."', Dien_thoai=N'".$post['Dien_thoai']."', Email=N'".$post['Email']."',Ma_so_thue=N'".$post['Ma_so_thue']."', Thong_tin_them=N'".$post['Thong_tin_them']."'  WHERE ID=N'".$post['ID']."' ",dbconnect()); 	
	}
 
?>